package com.jingjiu.homeservicesbiz.controller;

import java.util.List;

import com.jingjiu.homeservicesapi.domain.HouseServiceOrder;
import com.jingjiu.homeservicesbiz.service.IHouseServiceOrderService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 家政订单：记录家政服务的订单详情Controller
 * 
 * @author ruoyi
 * @date 2025-04-16
 */
@Controller
@RequestMapping("/Houseservice/system/order")
public class HouseServiceOrderController extends BaseController
{

    @Autowired
    private IHouseServiceOrderService houseServiceOrderService;


    /**
     * 查询家政订单：记录家政服务的订单详情列表
     */
    @RequiresPermissions("system:order:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HouseServiceOrder houseServiceOrder)
    {
        startPage();
        List<HouseServiceOrder> list = houseServiceOrderService.selectHouseServiceOrderList(houseServiceOrder);
        return getDataTable(list);
    }

    /**
     * 导出家政订单：记录家政服务的订单详情列表
     */
    @RequiresPermissions("system:order:export")
    @Log(title = "家政订单：记录家政服务的订单详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(@RequestBody HouseServiceOrder houseServiceOrder)
    {
        List<HouseServiceOrder> list = houseServiceOrderService.selectHouseServiceOrderList(houseServiceOrder);
        ExcelUtil<HouseServiceOrder> util = new ExcelUtil<HouseServiceOrder>(HouseServiceOrder.class);
        return util.exportExcel(list, "家政订单：记录家政服务的订单详情数据");
    }


    /**
     * 新增保存家政订单：记录家政服务的订单详情
     */
    @RequiresPermissions("system:order:add")
    @Log(title = "家政订单：记录家政服务的订单详情", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody HouseServiceOrder houseServiceOrder)
    {
        return toAjax(houseServiceOrderService.insertHouseServiceOrder(houseServiceOrder));
    }

    /**
     * 修改家政订单：记录家政服务的订单详情
     */
    @RequiresPermissions("system:order:edit")
    @GetMapping("/get/{id}")
    public HouseServiceOrder getById(@PathVariable("id") Long id)
    {
        HouseServiceOrder houseServiceOrder = houseServiceOrderService.selectHouseServiceOrderById(id);

        return houseServiceOrder;
    }

    /**
     * 修改保存家政订单：记录家政服务的订单详情
     */
    @RequiresPermissions("system:order:edit")
    @Log(title = "家政订单：记录家政服务的订单详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody HouseServiceOrder houseServiceOrder)
    {
        return toAjax(houseServiceOrderService.updateHouseServiceOrder(houseServiceOrder));
    }

    /**
     * 删除家政订单：记录家政服务的订单详情
     */
    @RequiresPermissions("system:order:remove")
    @Log(title = "家政订单：记录家政服务的订单详情", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(houseServiceOrderService.deleteHouseServiceOrderByIds(ids));
    }
}
